import { HIDDEN_PAGE_COMMENTS_ELEM_ID, HIGHLIGHT_CLASS } from "~utils/constants";

const loadPage = (highlightVal) => {
  console.log("loading page comments...");
  const pageCommentsElem = document.getElementById(HIDDEN_PAGE_COMMENTS_ELEM_ID);

  console.log(`found page comments element: ${pageCommentsElem}`);
  console.log("highlighting page comments...");
  if (pageCommentsElem) {
    pageCommentsElem.classList.add(HIGHLIGHT_CLASS);
    pageCommentsElem.dataset.highlightId = highlightVal.uuid;
    pageCommentsElem.textContent = highlightVal.comments;
    pageCommentsElem.setAttribute("viewstate", highlightVal.viewstate);
  }
}

export default loadPage;
